package com.tfswue.cxy.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tfswue.cxy.entity.User;
import com.tfswue.cxy.mapper.UserMapper;
import com.tfswue.cxy.service.UserService;
import lombok.NonNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.ObjectOutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/getUser")
    public String getUser()
    {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("id",1);
    //    queryWrapper.like("username","t");

        List<User> list = userService.list(queryWrapper);
        return String.valueOf(userService.getById(1));
    }
//
//    @GetMapping("/{id}")
//    public User getUserById(@NonNull @PathVariable Long id){
//        return UserMap.getId;
//    }
//
//    @PostMapping
//    public User createUser(@RequestBody User user){
//        user.setId((int) nextId++);
//        userMap.put(Long.valueOf(user.getId()), user);
//        return user;
//    }
//
//    //更新用户
//    @PutMapping("/{id}")
//    public User updateUser(@PathVariable Long id, @RequestBody User userDatails){
//        User user = userMap.get(id);
//        if (user != null){
//            user.setEmail(userDatails.getEmail());
//        }
//    }
}
